<%@attribute name="mess" required="true" type="java.lang.String" %>
<%@ tag import="java.util.regex.Pattern" %>
<%@ tag import="java.util.regex.Matcher" %>
<%@variable name-given="price" variable-class="java.lang.String" scope="AT_BEGIN" %>
<%!
    public String getPriceSum(String input) {
        Pattern pattern;
        Matcher matcher;
        String regex = "-?[0-9]+(\\.[0-9]*)?";
//        -?:问号出现0-1次
//        [0-9]+:至少出现一个在0-9之间的数
//        [0-9]*:出现任意个在0-9之间的数
        pattern = Pattern.compile(regex);
        matcher = pattern.matcher(input);
        double sum = 0;
        while (matcher.find()) {
            String str = matcher.group();
            System.out.println(str);
            sum += Double.parseDouble(str);
        }
        return String.format("%.2f",sum);
    }
%>
<%
    jspContext.setAttribute("price", getPriceSum(mess));
%>